﻿namespace UnityEditor
{
    using System;
    using UnityEngine;

    internal class TerrainSplatContextMenus
    {
        [UnityEditor.MenuItem("CONTEXT/TerrainEngineSplats/Add Texture...")]
        internal static void AddSplat(MenuCommand item)
        {
            TerrainSplatEditor.ShowTerrainSplatEditor("Add Terrain Texture", "Add", (Terrain) item.context, -1);
        }

        [UnityEditor.MenuItem("CONTEXT/TerrainEngineSplats/Edit Texture...")]
        internal static void EditSplat(MenuCommand item)
        {
            TerrainSplatEditor.ShowTerrainSplatEditor("Edit Terrain Texture", "Apply", (Terrain) item.context, item.userData);
        }

        [UnityEditor.MenuItem("CONTEXT/TerrainEngineSplats/Edit Texture...", true)]
        internal static bool EditSplatCheck(MenuCommand item)
        {
            Terrain context = (Terrain) item.context;
            return ((item.userData >= 0) && (item.userData < context.terrainData.splatPrototypes.Length));
        }

        [UnityEditor.MenuItem("CONTEXT/TerrainEngineSplats/Remove Texture")]
        internal static void RemoveSplat(MenuCommand item)
        {
            Terrain context = (Terrain) item.context;
            TerrainEditorUtility.RemoveSplatTexture(context.terrainData, item.userData);
        }

        [UnityEditor.MenuItem("CONTEXT/TerrainEngineSplats/Remove Texture", true)]
        internal static bool RemoveSplatCheck(MenuCommand item)
        {
            Terrain context = (Terrain) item.context;
            return ((item.userData >= 0) && (item.userData < context.terrainData.splatPrototypes.Length));
        }
    }
}

